package com.kechen.servlet;

import com.kechen.dao.EmpDao;
import com.kechen.pojo.Employee;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//@WebServlet("/update")
public class UpdateServlet extends HttpServlet {

    private static final long serialVersionUID = 1L;

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        int id=Integer.parseInt(request.getParameter("id"));
        String name=request.getParameter("name");
        String age=request.getParameter("age");
        Employee emp=new Employee();
        emp.setId(id);
        emp.setName(name);
        emp.setAge(age);
        EmpDao dao=new EmpDao();
        dao.updateEmp(emp);
        response.sendRedirect("GetServlet");
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}

